package com.yiwangqingshui.jmx.mbean;

import javax.management.*;

/**
 * @author smc
 * @date 2019-01-30 15:06
 * @since
 **/
public class Hello implements HelloMBean,NotificationBroadcaster {

    private int cache;

    @Override
    public void say(String content) {
        System.out.printf("hello you say ： %s \n",content);
    }

    @Override
    public String getMemory() {
        System.out.println("get freememory");
        Runtime runtime = Runtime.getRuntime();
        return String.valueOf(runtime.freeMemory());
    }

    @Override
    public void setCache(int cache) {
        System.out.println("set cache");
        this.cache = cache;
    }

    @Override
    public int getCache() {
        return this.cache;
    }

    @Override
    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
        System.out.println("mbean 中增加通知监听.. NotificationListener: "+ listener+" ,NotificationFilter: "+ filter+" ,handback: "+handback);
    }

    @Override
    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
        System.out.println("移除了监听....");
    }

    @Override
    public MBeanNotificationInfo[] getNotificationInfo() {
        return new MBeanNotificationInfo[0];
    }




}
